<?php

    if($blockSettings['position']!=""){
        $position = explode("x",$blockSettings['position']);
    } else {
        $position[0] = "";
        $position[1] = "";
        $position[2] = "";
        $position[3] = "";
    }
?>

<div class="block" id="block-<?php echo $blockSettings['ID'];?>" top="<?php echo $position[0]; ?>" left="<?php echo $position[1]; ?>" height="<?php echo $position[2]; ?>" width="<?php echo $position[3]; ?>">
    <button id="switchMain-<?php echo $blockSettings['ID'];?>" class="switchMain"></button>
    <button id="switchUser-<?php echo $blockSettings['ID'];?>" class="switchUser"></button>
    <h2><?php echo $blockSettings['title']; ?></h2>
    <div class="blockcontent">
        <?php
           /* $twitterControl = new Model_Blocks_Twitter();
            $twitterSettings = explode(",",$blockSettings['setting']);
            
            if(!isset($twitterSettings[3])) $twitterSettings[3] = 'main';

            if($twitterSettings[3]=="user"){
                $tweetFeed = $twitterControl->getUserTimeline($twitterSettings[0],$twitterSettings[1],$twitterSettings[2]);
            } else {
                $tweetFeed = $twitterControl->getMainTimeline($twitterSettings[0],$twitterSettings[1],$twitterSettings[2]);
            }

            if(isset($tweetFeed->error)){
                echo $tweetFeed->error;
            } else {
                $tweets = $tweetFeed->xpath('status');

                foreach($tweets as $tweet){ ?>
                    <div class="tweet">
                        <?php echo $tweet->text; ?>
                        <hr />
                        <span class="details">
                            <?php
                                echo __('Tweeted at');
                                echo " ";
                                echo $tweet->created_at;
                                echo ", ";
                                echo __('using');
                                echo " ";
                                echo $tweet->source;
                                if($tweet->in_reply_to_screen_name != ''){
                                    echo ", ";
                                    echo __('in reply to').": ".$tweet->in_reply_to_screen_name;
                                }
                            ?>
                        </span>
                    </div><?php
                }
            } */
        ?>
    </div>
    <div class="blockfooterline"></div>
    <div class="blockfooter">
        <?php echo $blockSettings['type']; ?>
        <button id="delete-<?php echo $blockSettings['ID'];?>"></button>
        <button id="edit-<?php echo $blockSettings['ID'];?>"></button>
    </div>
</div>
<script language="text/javascript">
    $("#switchUser-"+<?php echo $blockSettings['ID'];?>).button({
        icons: {
            primary: 'ui-icon-person'
        },
        text: false
    }).bind('click',function(){
        $.get("ajax/retrieveBlock/<?php echo $blockSettings['ID'];?>/UserTimeline",
        function(responseText){
            $("#block-<?php echo $blockSettings['ID'];?>").find('.blockcontent').html(responseText);
        });
    }).css('margin-top','2px');

    $("#switchMain-"+<?php echo $blockSettings['ID'];?>).button({
        icons: {
            primary: 'ui-icon-home'
        },
        text: false
    }).bind('click',function(){
        $.get("ajax/retrieveBlock/<?php echo $blockSettings['ID'];?>/MainTimeline",
        function(responseText){
            $("#block-<?php echo $blockSettings['ID'];?>").find('.blockcontent').html(responseText);
        });
    }).css('margin-top','2px');
</script>